![]() |
CreateResFile |
||||
Header: | Resources.h | Carbon status: | Unsupported | |
Creates an empty resource fork, when the FSpCreateResFile function is not available.
void CreateResFile ( ConstStr255Param fileName );
The name of the file to be created. The function creates a file with an empty resource fork in your application’s default directory—that is, the directory in which your application is located.
If no other file with the given name exists in the default directory or any of the other directories searched by the PBOpenRF function, this function creates a resource file—that is, a resource fork, including a resource map. In this case the file has a zero-length data fork.
If a file with the specified name already exists and includes a resource fork with a resource map, this function does nothing. Call the ResError function to determine whether an error occurred. If the data fork of the specified file already exists but the file has a zero-length resource fork, this function creates an empty resource fork and resource map for the file.
This function first checks whether a file with the specified name exists. (If so, ResError returns the result code dupFNErr.) To perform this check, CreateResFile calls PBOpenRF, which looks first in the default directory for a file with the same name, then in the root directory of the boot volume (if the default directory is on the boot volume), and then in the System Folder (if one exists on the same volume as the default directory). It is thus impossible, for example, to use CreateResFile to create a file in the default directory if a file with the same name already exists in the System Folder. To avoid this problem, use the FSpCreateResFile function or the HCreateResFile function whenever possible.
The HCreateResFile function allows you to specify a directory ID and a volume reference number, and is therefore preferred over CreateResFile. The CreateResFile function is an earlier version of HCreateResFile that is still supported but has more restricted capabilities.
Don’t use the resource fork of a file for data that is not in resource format. The Resource Manager assumes that any information in a resource fork can be interpreted according to the standard resource format described in this chapter.
The File Manager assumes that the first block of a file’s resource fork is part of the resource header and puts information there that it uses during scavenging—for example, after the user presses the Reset switch. For this reason, if you copy a resource file, the duplicate may not be exactly like the original.
Before you can work with the newly created file’s resource fork, you must use the OpenResFile function or a related function to open it.
This function may move or purge memory blocks in the application heap. Your application should not call this function at interrupt time.
Not supported in Carbon. Not available in Carbon.
© 2000 Apple Computer, Inc. — (Last Updated 5/8/2000)